package com.newdream.clientdemo.controller;

import com.newdream.clientdemo.model.Student;
import com.newdream.clientdemo.model.User;
import com.newdream.clientdemo.service.StudentService;
import com.newdream.clientdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ author: sanglei
 * @ date: 2019-04-30 10:03
 * @ description:
 */
@RestController
public class TestController {

    @Autowired
    private UserService userService;
    @Autowired
    private StudentService studentService;

    @GetMapping("test")
    public Object test(){
        return "test client-demo";
    }

    @GetMapping("get")
    public User selectUser(@RequestParam("id") Integer id){
        System.out.println("这是eureka-client2返回的数据");
        User user = userService.getUserById(id);
        return user;
    }
    @GetMapping("dev")
    public Object dev(@RequestParam("id") Integer id){
        Student student = studentService.get(id);
        return student;
    }
}
